package com.xingongchang.baolebei.protocol;

import com.external.activeandroid.annotation.Table;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.external.activeandroid.annotation.Column;

@Table(name = "BONUS")
public class BONUS {
	@Column(name = "type_id")
	public int type_id;

	@Column(name = "type_name")
	public String type_name;

	@Column(name = "type_money")
	public String type_money;

	@Column(name = "bonus_id")
	public String bonus_id;

	@Column(name = "bonus_money_formated")
	public String bonus_money_formated;

	public static BONUS fromJson(JSONObject jsonObject) throws JSONException {
		if (null == jsonObject) {
			return null;
		}

		BONUS localItem = new BONUS();

		localItem.type_id = jsonObject.optInt("type_id");
		localItem.type_name = jsonObject.optString("type_name");
		localItem.type_money = jsonObject.optString("type_money");
		localItem.bonus_id = jsonObject.optString("bonus_id");
		localItem.bonus_money_formated = jsonObject
				.optString("bonus_money_formated");
		return localItem;
	}

	public JSONObject toJson() throws JSONException {
		JSONObject localItemObject = new JSONObject();
		localItemObject.put("type_id", type_id);
		localItemObject.put("type_name", type_name);
		localItemObject.put("type_money", type_money);
		localItemObject.put("bonus_id", bonus_id);
		localItemObject.put("bonus_money_formated", bonus_money_formated);
		return localItemObject;
	}

}
